//name代表你要写的名称
const mongoose = require("./db");

// 用户信息
let userSchema = new mongoose.Schema({
  username: String,
  password: String,
  img: String,
  tel: Number,
  name: String,
  Idnumber: String,
  sex: String,
  birthday: Date,
  imgflag: String,
  email: String,
});

// 首页信息

// 热销推荐
let hotSchema = new mongoose.Schema({
  img: String,
  title: String,
  price: Number,
  inventory: Number,
  qualities: [{ level: Number, quantity: Number, img: String }],
});

let hotMoreSchema = new mongoose.Schema({
  img: String,
  title: String,
  price: Number,
  inventory: Number,
  qualities: [{ level: Number, quantity: Number }],
});

let hotMoreModel = mongoose.model("hotMore", hotMoreSchema, "hotMore");

// 一番赏
let appreciateSchema = new mongoose.Schema({
  img: String,
  title: String,
  price: Number,
  inventory: Number,
  qualities: [{ level: Number, quantity: Number }],
});
// 新品专区
let newListSchema = new mongoose.Schema({
  img: String,
  title: String,
  price: Number,
});
// 用户信息字段
let userModel = mongoose.model("user", userSchema, "user");
// 热销推荐字段
let hotModel = mongoose.model("hot", hotSchema, "hot");
// 一番赏字段
let appreciateModel = mongoose.model(
  "appreciate",
  appreciateSchema,
  "appreciate"
);
// 新品专区字段
let newListModel = mongoose.model("newList", newListSchema, "newList");

//我的
const myScheam = new mongoose.Schema({
  name: String,
  img: String,
  ID: String,
  Code: String,
});

const myModule = mongoose.model("my", myScheam, "my");

//优惠卷
const couponSchema = new mongoose.Schema({
  name: String,
  price: Number,
  expiryDate: Date,
  minSpend: Number,
});
const couponModule = mongoose.model("coupon", couponSchema, "coupon");

//道具卡
const propSchema = new mongoose.Schema({
  image: String,
  type: String,
  description: String,
  usage: String,
  count: Number,
});
const propModule = mongoose.model("prop", propSchema, "prop");

const chatHistorySchema = new mongoose.Schema({
  userid: String,
  message: String,
})
const chatHistoryModule = mongoose.model("chatHistory", chatHistorySchema, "chatHistory")

module.exports = {
  userModel,
  myModule,
  couponModule,
  propModule,
  hotModel,
  appreciateModel,
  newListModel,
  hotMoreModel,
  chatHistoryModule
};
